package com.probiz.estore.system.service.impl;

import java.util.List;

import com.probiz.estore.common.model.system.TaxRate;
import com.probiz.estore.common.model.system.TaxRate.FilterHqlName;
import com.probiz.estore.core.service.impl.GenericManagerImpl;
import com.probiz.estore.system.dao.TaxRateDao;

public class TaxRateManagerImpl extends GenericManagerImpl<TaxRate> implements com.probiz.estore.system.service.TaxRateManager {
	private TaxRateDao taxRateDao = null;
	
	public void setTaxRateDao(TaxRateDao taxRateDao) {
		this.taxRateDao = taxRateDao;
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.system.service.TaxRateManager#checkExist(com.probiz.estore.common.model.system.TaxRate)
	 */
	public boolean checkExist(TaxRate entity){
		if(entity.getTaxRateId()!=null)
			return this.taxRateDao.countByFilter(FilterHqlName.COUNT_EXIST_EXCLUDE_SELF, entity.getTaxId(), entity.getProductTypeId(), entity.getRegionId(), entity.getTaxRateId())>0?true:false;
		return this.taxRateDao.countByFilter(FilterHqlName.COUNT_EXIST, entity.getTaxId(), entity.getProductTypeId(), entity.getRegionId())>0?true:false;
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.system.service.TaxRateManager#getTaxRateListByRegionIdAndProductTypeId(java.lang.Integer, java.lang.Integer)
	 */
	public List<TaxRate> getTaxRateListByRegionIdAndProductTypeId(Integer regionId, Integer productTypeId){
		return taxRateDao.getTaxRateListByRegionIdAndProductTypeId(regionId, productTypeId);
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.system.service.TaxRateManager#countAll()
	 */
	public Long countAll(){
		return this.taxRateDao.countAll();
	}

	@Override
	protected void initManager() {
		this.dao = taxRateDao;
	}

	@Override
	protected void preDelete(TaxRate entity) {
		
	}

	@Override
	protected void preSave(TaxRate entity) {
		
	}
}

